package cj.com.chabaike.ui.utils;


import android.app.Activity;
import android.content.Intent;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.util.Pair;
import android.support.v4.view.ViewCompat;
import android.view.View;

import cj.com.chabaike.R;
import cj.com.chabaike.entity.EliteList;
import cj.com.chabaike.entity.NewsList;
import cj.com.chabaike.entity.Thing;
import cj.com.chabaike.entity.seach.Seach_ContentList;
import cj.com.chabaike.entity.special.Special_detail_data_list_conlist;
import cj.com.chabaike.ui.act.MainPager;

public class Navigator {

    public static int ANIM_DURATION = 350;

    public static void launchDetail(MainPager fromActivity, View fromView, EliteList item, View backgroundView) {
        ViewCompat.setTransitionName(fromView, "detail_element");
       // ViewCompat.setTransitionName(fromActivity.findViewById(R.id.fab), "fab");
        ActivityOptionsCompat options =
                TransitionHelper.makeOptionsCompat(
                        fromActivity,
                        Pair.create(fromView, "detail_element")
                        //Pair.create(fromActivity.findViewById(R.id.fab), "fab")
                );
        Intent intent = new Intent(fromActivity, MainPager.class);
        intent.putExtra("item_text", item.getTitle());
        intent.putExtra("EliteList",item);
        intent.putExtra("fragment_resource_id", R.layout.fragment_thing_detail);

        if (backgroundView != null) BitmapUtil.storeBitmapInIntent(BitmapUtil.createBitmap(backgroundView), intent);

        ActivityCompat.startActivity(fromActivity, intent, options.toBundle());

        fromActivity.overridePendingTransition(R.anim.slide_up, R.anim.scale_down);
    }


    public static void launchDetailNews(MainPager fromActivity, View fromView, NewsList item, View backgroundView) {
        ViewCompat.setTransitionName(fromView, "detail_element");
        // ViewCompat.setTransitionName(fromActivity.findViewById(R.id.fab), "fab");
        ActivityOptionsCompat options =
                TransitionHelper.makeOptionsCompat(
                        fromActivity,
                        Pair.create(fromView, "detail_element")
                        //Pair.create(fromActivity.findViewById(R.id.fab), "fab")
                );
        Intent intent = new Intent(fromActivity, MainPager.class);
        intent.putExtra("item_text", item.getTitle());
        intent.putExtra("NewsList",item);
        intent.putExtra("fragment_resource_id", R.layout.fragment_thing_detail);

        if (backgroundView != null) BitmapUtil.storeBitmapInIntent(BitmapUtil.createBitmap(backgroundView), intent);

        ActivityCompat.startActivity(fromActivity, intent, options.toBundle());

        fromActivity.overridePendingTransition(R.anim.slide_up, R.anim.scale_down);
    }

    public static void launchDetailSeach(Activity fromActivity, View fromView, Seach_ContentList item, View backgroundView) {
        ViewCompat.setTransitionName(fromView, "detail_element");
        // ViewCompat.setTransitionName(fromActivity.findViewById(R.id.fab), "fab");
        ActivityOptionsCompat options =
                TransitionHelper.makeOptionsCompat(
                        fromActivity,
                        Pair.create(fromView, "detail_element")
                        //Pair.create(fromActivity.findViewById(R.id.fab), "fab")
                );
        Intent intent = new Intent(fromActivity, MainPager.class);
        intent.putExtra("item_text", item.getTitle());
        intent.putExtra("Seach_ContentList",item);
        intent.putExtra("fragment_resource_id", R.layout.fragment_thing_detail);

        if (backgroundView != null) BitmapUtil.storeBitmapInIntent(BitmapUtil.createBitmap(backgroundView), intent);

        ActivityCompat.startActivity(fromActivity, intent, options.toBundle());

        fromActivity.overridePendingTransition(R.anim.slide_up, R.anim.scale_down);
    }


    public static void launchDetailSeach(Activity fromActivity, View fromView, Special_detail_data_list_conlist item, View backgroundView) {
        ViewCompat.setTransitionName(fromView, "detail_element");
        // ViewCompat.setTransitionName(fromActivity.findViewById(R.id.fab), "fab");
        ActivityOptionsCompat options =
                TransitionHelper.makeOptionsCompat(
                        fromActivity,
                        Pair.create(fromView, "detail_element")
                        //Pair.create(fromActivity.findViewById(R.id.fab), "fab")
                );
        Intent intent = new Intent(fromActivity, MainPager.class);
        intent.putExtra("item_text", item.getTitle());
        intent.putExtra("Special_detail_data_list_conlist",item);
        intent.putExtra("fragment_resource_id", R.layout.fragment_thing_detail);

        if (backgroundView != null) BitmapUtil.storeBitmapInIntent(BitmapUtil.createBitmap(backgroundView), intent);

        ActivityCompat.startActivity(fromActivity, intent, options.toBundle());

        fromActivity.overridePendingTransition(R.anim.slide_up, R.anim.scale_down);
    }



    public static void launchSpecial_DetailSeach(Activity fromActivity, View fromView, String Special_Detail_url, View backgroundView) {
        ViewCompat.setTransitionName(fromView, "detail_element");
        // ViewCompat.setTransitionName(fromActivity.findViewById(R.id.fab), "fab");
        ActivityOptionsCompat options =
                TransitionHelper.makeOptionsCompat(
                        fromActivity,
                        Pair.create(fromView, "detail_element")
                        //Pair.create(fromActivity.findViewById(R.id.fab), "fab")
                );
        Intent intent = new Intent(fromActivity, MainPager.class);

        intent.putExtra("Special_detail_data_url", Special_Detail_url);
        intent.putExtra("fragment_resource_id", R.layout.special_detail_pager);
        if (backgroundView != null) BitmapUtil.storeBitmapInIntent(BitmapUtil.createBitmap(backgroundView), intent);

        ActivityCompat.startActivity(fromActivity, intent, options.toBundle());

        fromActivity.overridePendingTransition(R.anim.slide_up, R.anim.scale_down);
    }


/*
    public static void launchOverlay(MainPager fromActivity, View fromView, View backgroundView) {
        ActivityOptionsCompat options =
                TransitionHelper.makeOptionsCompat(
                        fromActivity
                );
        Intent intent = new Intent(fromActivity, MainPager.class);
        intent.putExtra("fragment_resource_id", R.layout.fragment_overaly);

        if (backgroundView != null) BitmapUtil.storeBitmapInIntent(BitmapUtil.createBitmap(backgroundView), intent);

        ActivityCompat.startActivity(fromActivity, intent, options.toBundle());

        fromActivity.overridePendingTransition(R.anim.slide_up, R.anim.scale_down);
    }
*/
}
